import React from "react"
import {connect} from "react-redux"
import {addGun,removeGun,addGunAsync} from "./index.redux";

class App extends React.Component{
    render(){
        return(
            <div>
                <h1>现在有机枪{this.props.num}把</h1>
                {/*处理任务*/}
                <button onClick={this.props.addGun}> 申请机枪</button>
                <button onClick={this.props.removeGun}>上交机枪</button>
                <button onClick={this.props.addGunAsync}>拖两天再给</button>
            </div>
        )
    }
}

const mapStatetoProps=(state)=>{
    return {num:state}
}
const actionCreactors={addGun,removeGun,addGunAsync}
App=connect(mapStatetoProps,actionCreactors)(App)
export default App;